﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Microsoft.Practices.Unity;

namespace Shop.Infrastructure.Web
{
    public class ShopControllerFactory : DefaultControllerFactory
    {
        public IUnityContainer Container
        {
            get;
            set;
        }

        public ShopControllerFactory(IUnityContainer container)
        {
            this.Container = container;
        }

        protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
        {
            if (controllerType == null)
            {
                return base.GetControllerInstance(requestContext, controllerType);
            }
            IController icontroller = this.Container.Resolve(controllerType) as IController;
            return icontroller;
        }
    }
}
